﻿using System;
using System.ComponentModel;
using CthulhuDomain.GameEntities;
using CthulhuDomain.Services;
using Microsoft.Pex.Framework.Validation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Pex.Framework;
using Microsoft.Xna.Framework.Input;
using CthulhuDomain;
using Microsoft.Xna.Framework;

namespace Invaders.Test
{
  //public partial class InvadersFixture
  //{

  //  [PexMethod]
  //  [PexAllowedException(typeof(InvalidEnumArgumentException))]
  //  public void CreateOfDomainEntity_IstanceShouldBeNotNull(DomainFactory.eTypeEntity typeEntity)
  //  {
  //    // Act
  //    var factory = CreateOfFactory_InstanceShouldBeNotNull(typeEntity);
  //    var entity = factory.CreateEntity(new ContentManagerAdapter(contentManager));

  //    // Assert
  //    PexAssert.IsNotNull(entity, "Instance entity is null");
  //  }

  //  [PexMethod]
  //  public void IstanceOfCthulhu_Position_AfterMoveNext_ShouldBeIncremented(Vector2 oldPosition, int width, int totalElapsed, int elapsed)
  //  {
  //    // Arrange
  //    var recAdapter = new RectangleAdapter(0, 0, width, 100);
  //    var time =new GameTimeAdapter(new GameTime(new TimeSpan(0, 0, 0, totalElapsed), new TimeSpan(0, 0, 0, elapsed)));

  //    // Act

  //    var factory = CreateOfFactory_InstanceShouldBeNotNull(DomainFactory.eTypeEntity.Cthulhu);
  //    var entity = factory.CreateEntity(new ContentManagerAdapter(contentManager));

  //    entity.Position = new Vector2Adapter(oldPosition.X, oldPosition.Y);

  //    entity.Update(recAdapter, time);
  //    entity.Move(recAdapter, time);

  //    var newPos = entity.Position;

  //    // Assert

  //    Assert.IsTrue(newPos.X > oldPosition.X, "After Move next Chtulhu position is not changed");
  //  }

  //  [PexMethod]
  //  public void PlayerPosition_AfterKeyRightPress_ShouldBeChanged(int width, Vector2 oldPosition)
  //  {

  //    PexAssume.IsTrue(width > 0 && width < int.MaxValue);
  //    PexAssume.IsTrue(oldPosition.X > 0 && oldPosition.X < width);
  //    // Arrange

  //    var recAdapter = new RectangleAdapter(0, 0, width, 100);
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 20));
  //    var factory = DomainFactory.GetFactory(DomainFactory.eTypeEntity.Player);
  //    var player = factory.CreateEntity(new ContentManagerAdapter(contentManager));
  //    player.Position = new Vector2Adapter(oldPosition.X, oldPosition.Y);

  //    var keys = new[] { Keys.Right };
  //    // ACT
  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);
  //    var newPos = player.Position;

  //    // Assert
  //    Assert.IsTrue(newPos.X > oldPosition.X, "After [Right] press Player position is not changed");
  //  }

  //  [PexMethod]
  //  public void PlayerPosition_AfterKeyLeftPress_ShouldBeChanged(int width, Vector2 oldPosition)
  //  {
  //    PexAssume.IsTrue(width > 0 && width < int.MaxValue);
  //    PexAssume.IsTrue(oldPosition.X > 0 && oldPosition.X < width);
  //    // Arrange

  //    var recAdapter = new RectangleAdapter(0, 0, width, 100);
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 20));
  //    var factory = DomainFactory.GetFactory(DomainFactory.eTypeEntity.Player);
  //    var player = factory.CreateEntity(new ContentManagerAdapter(contentManager));
  //    player.Position = new Vector2Adapter(oldPosition.X, oldPosition.Y);

  //    var keys = new[] { Keys.Left };
  //    // ACT
  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);
  //    var newPos = player.Position;

  //    // Assert
  //    Assert.IsTrue(newPos.X < oldPosition.X, "After [Left] press Player Position is not changed");
  //  }

  //  [PexMethod]
  //  public void PlayerPosition_AfterKeyLeftPress_ShouldNotBeChanged(int width, Vector2 oldPosition)
  //  {
  //    PexAssume.IsTrue(width > 0 && width < int.MaxValue);
  //    PexAssume.IsTrue(Math.Abs(oldPosition.X - 0) < 1 && oldPosition.X < width);
  //    // Arrange

  //    var recAdapter = new RectangleAdapter(0, 0, width, 100);
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 20));
  //    var factory = DomainFactory.GetFactory(DomainFactory.eTypeEntity.Player);
  //    var player = factory.CreateEntity(new ContentManagerAdapter(contentManager));
  //    player.Position = new Vector2Adapter(0, oldPosition.Y);
  //    var oldPos = player.Position;
  //    var keys = new[] { Keys.Left };
  //    // ACT

  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);
  //    var newPos = player.Position;

  //    Assert.IsTrue(Math.Abs(newPos.X - oldPos.X) < 0.1, "After [Left] press Player on bound Left position is changed");
  //  }

  //  [PexMethod]
  //  public void PlayerPosition_AfterKeySpacePress_ShouldBeNotChanged(int width, Vector2 oldPosition)
  //  {
  //    PexAssume.IsTrue(width > 0 && width < int.MaxValue);
  //    PexAssume.IsTrue(oldPosition.X > 0 && oldPosition.X < width);
  //    // Arrange

  //    var recAdapter = new RectangleAdapter(0, 0, width, 100);
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 20));
  //    var factory = DomainFactory.GetFactory(DomainFactory.eTypeEntity.Player);
  //    var player = factory.CreateEntity(new ContentManagerAdapter(contentManager));
  //    player.Position = new Vector2Adapter(oldPosition.X, oldPosition.Y);

  //    var keys = new[] { Keys.Space };

  //    // ACT
  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);
  //    var newPos = player.Position;

  //    // Assert
  //    Assert.IsTrue(Math.Abs(newPos.X - oldPosition.X) < 1, "After [Space] press player position is changed");
  //  }

  //  [PexMethod]
  //  public DomainEntity PlayerBullet_AfterKeySpacePress_ShouldBeIncreasedByOne(int _x, int _y)
  //  {
  //    PexAssume.IsTrue(_x > 0 && _x < 300);

  //    // Arrange
  //    var factory = DomainFactory.GetFactory(DomainFactory.eTypeEntity.Player);
  //    var player = factory.CreateEntity(new ContentManagerAdapter(contentManager), new PlayerState
  //    {
  //      LifePoints = 3,
  //      StartingPosition = new Vector2Adapter(_x, _y)
  //    });
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 20));
  //    var recAdapter = new RectangleAdapter(0, 0, _x, 100);

  //    var keys = new[] { Keys.Space };
  //    var oldShootNum = player.Shoots.Count;
  //    // ACT
  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);

  //    // ASSERT
  //    Assert.IsTrue(player.Shoots.Count - oldShootNum == 1, "After collision shoot is not removed");

  //    return player;
  //  }

  //  [PexMethod]
  //  public void PlayerBulletPosition_AfterNextUpdate_ShouldBeDecreased(int _x, int _y)
  //  {
  //    PexAssume.IsTrue(_x > 0 && _x < 300);
  //    PexAssume.IsTrue(_y > 100 && _x < 300);

  //    var player = PlayerBullet_AfterKeySpacePress_ShouldBeIncreasedByOne(_x, _y);
  //    var time = new GameTime(new TimeSpan(0, 0, 0, 20), new TimeSpan(0, 0, 0, 30));
  //    var recAdapter = new RectangleAdapter(0, 0, _x, _y);

  //    var keys = new[] { Keys.Right };
  //    var SUTshoot = (Shoot)player.Shoots[0];
  //    var oldPos = SUTshoot.Position.Y;

  //    player.Update(recAdapter, keys);
  //    player.Move(recAdapter, keys);

  //    Assert.IsTrue(SUTshoot.Position.Y < oldPos, "shoot position is not changed");
  //  }

  //}
}
